
<template >
    <div>
        <span>子组件的值{{num}}</span>
        <el-button @click="handEvent('add')">增加</el-button>
        <el-button @click="handEvent('down')">减少</el-button>
    </div>
</template>
<script>
export default {
    props:['propnum'],
    data() {
        return {
            num: this.propnum,
            optionType: ["add","down"]
        }
    },
    methods:{
        handEvent(params) {
            if (params == this.optionType[0]) {

                this.num++
            }
            if (params == this.optionType[1]) {
                this.num--
            }
            // 暴露函数出去
            this.$emit('childEvent',this.num)
        }
    }
}
</script>